﻿using System;

namespace RockBus.Utilities
{
    public static class Convertor
    {
        /// <summary>
        ///     Casts/Converts a boolean to an integer
        /// </summary>
        /// <param name="boolValue">Boolean to cast/convert.</param>
        /// <returns>Int32</returns>
        public static int BooleanToInt32(bool boolValue)
        {
            switch(boolValue)
            {
                case true:
                    return 1;
                case false:
                    return 0;
                default:
                    throw new InvalidCastException();
            }
        }

        /// <summary>
        ///     Casts/Converts an integer to a boolean
        /// </summary>
        /// <param name="intValue">Int32 to cast/convert.</param>
        /// <returns>Int32</returns>
        public static bool Int32ToBoolean(int intValue)
        {
            switch(intValue)
            {
                case 1:
                    return true;
                case 0:
                    return false;
                default:
                    throw new InvalidCastException();
            }
        }
    }
}
